mini.parse();
var form = new mini.Form("form1");
var auditEmp = mini.getByName('auditEmp');
var aaa = [
    {"id":"0","text":"1"},
    {"id":"1","text":"2"},
];
var name99=mini.get("name99");
name99.setData(aaa);
function CloseWindow(action) {
    if (action == "close" && form.isChanged()) {
        if (confirm("数据被修改了，是否先保存？")) {
            return false;
        }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
}

function onOk(e) {
    saveData();
}

function onCancel(e) {
    CloseWindow("cancel");
}
function onButtonEdit() {
    mini.open({
        targetWindow: window,
        url:"Departmentlist.html",
        title:"选择部门人员",
        height:700,
        width:800,
        showMaxButton: true,
        showModal:Boolean,
        allowResize:Boolean,
        setReadOnly:false,
        onload: function () {

        },
        ondestroy: function (action) {
            if(action=="save"){
                var iframe = this.getIFrameEl();
                var data = iframe.contentWindow.GetData();
                data = mini.clone(data);    //必须
                console.log(data,'子页面传来的')
                if (data.length > 0) {
                    var ids = [];
                    var names = [];
                    for (var i = 0, l = data.length; i < l; i++) {
                        var r = data[i];
                        ids.push(r.PersonnelFiles_id);
                        names.push(r.PersonnelFiles_OperatorName);
                    }
                    var id = ids.join(',');
                    var nameText = names.join(',');
                    auditEmp.setValue(id);
                    auditEmp.setText(nameText);
                } else {
                    mini.alert("请选中一条记录");
                }

            }
        }
    })
}


//查询空闲车辆
function getFreeCar() {
    
}

//保存用车申请信息
function saveData() {
   // 校验
    form.validate();
    if (form.isValid() == false) {

        return;
    }
    var formData = form.getData();
    console.log(formData)
    var msgStr = JSON.stringify(formData);
    $.ajax({
        url:  ajaxUrl + '/carApply/saveCarApply.do',
        type: 'post',
        contentType : "application/json",
        data: msgStr,
        success : function(data){
          mini.alert(data.msg)
            CloseWindow("cancel")
            request(0,pager.getPageSize())
        },
        error: function(msg){
            mini.alert('请求失败');
        }
    })
}